package com.qf.controller;

import com.qf.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/param")
public class ParamController {
    @RequestMapping("/lian1")
    public String param(HttpServletRequest request, Model model){
        String id = request.getParameter("id");
        String name = request.getParameter("name");
        System.out.println("========id========"+id);
        System.out.println("========name========"+name);
        model.addAttribute("id",id);
        model.addAttribute("name",name);
        return "hello";
    }
    @RequestMapping("/lian2")
    public String param2(Integer id,String name,Model model){
//        String id = request.getParameter("id");
//        String name = request.getParameter("name");
        System.out.println("========id========"+id);
        System.out.println("========name========"+name);
        model.addAttribute("id",id);
        model.addAttribute("name",name);
        return "hello";
    }
    @RequestMapping("/lian3")
    public String param3(String[] str ,Model model){
        String id=str[0];
        String name=str[1];
        System.out.println("========id========"+id);
        System.out.println("========name========"+name);
        model.addAttribute("id",id);
        model.addAttribute("name",name);
        return "hello";
    }
    @RequestMapping("/lian4")
    public String param4(User user,Model model){

        System.out.println("====user===="+user);
        model.addAttribute("user",user);
        return "hello";
    }
    @RequestMapping("/lian5")
    public String param5(Integer id, Model model){
        System.out.println("=====userMvc======="+id);

        return "hello";
    }

}
